#include "dominion.h"
#include <stdio.h>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>

int testGreatHall()
{
	printf("testing great hall.\n");
	//initializtaion
	struct gameState *G = newGame();
	struct gameState *G2 = (struct gameState*)malloc(sizeof(struct gameState));

	srand(time(NULL));
	int r = rand();
	
	// make sure we don't put gardens here
	// as the extra card may increase the count
	int k[10] = {adventurer, council_room, embargo, village, minion, mine, cutpurse, sea_hag, tribute, smithy};
	initializeGame(2, k, r, G);
	
	//ensuring we have everything setup
	//tocall playCard
	G->numActions = 1;
	G->whoseTurn = 0;
	G->hand[0][0] = great_hall;

	//copy G to G2 for s2s comparison later
	memcpy(G2, G, sizeof(struct gameState));

	printf("Testing to see if playCard errs when playing great hall.\n");
	assert(playCard(0, 0, 0, 0, G) == 0);
	printf("Test Passed.\n");

	printf("Testing to see if we gained +1 card.\n");
	assert(G2->handCount[0] == G->handCount[0]);
	printf("Test Passed.\n");

	printf("Testing to see if we gained 1 action.\n");
	assert(G2->numActions == G->numActions);
	printf("Test Passed.\n");

	printf("Testing to see if we gained 1 victory point.\n");
	// eliminate the card from existing
	G->playedCardCount = 0;
	assert(scoreFor(0, G2) == scoreFor(0, G) + 1);
	printf("Test Passed.\n");

	printf("All Tests Passed.\n");
	return 0;
}

int main()
{
	return testGreatHall();
}
